//
// Copyright (c) 1995 Molecular Structure Corporation
//
// RESTRICTED RIGHTS NOTICE SHORT FORM (JUNE 1987)
//
// Use, reproduction, or disclosure is subject to restrictions set
// forth in Contract No. W-31-109-ENG-38 and Contract No. 
// 943072401 with the University of Chicago, Operator of
// Argonne National Laboratory.
//
// tCdetector.cc        Initial author: J.W. Pflugrath           24-Mar-1995
//    This file tests the class Cdetector.
/*
 *
 * Copyright (C) 2014 Rigaku Americas Corporation
 *                    9009 New Trails Drive
 *                    The Woodlands, TX, USA  77381
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *    * Redistributions of source code must retain the above copyright
 *      notice(s), this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice(s), this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * Neither the name of the Rigaku Americas Corporation nor the 
 *      names of its contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL RIGAKU AMERICAS CORPORATION BE LIABLE 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA OR PROFITS; OR BUSINESS INTERUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
*/ 
//+Description
//  
//+ToDo
//
//   Error messages need implementing
//
//+Include files

#include <iostream.h>
#include "Dtrek.h"
#include "Cdetector.h"
#include "Csource.h"
#include "Cstring.h"

//+Code begin

int main()
{
  Cdetector *poDetector;
  Csource   *poSource;
  Cimage    *poImage;
  Cstring   sName;
  int       nStat;
  float     fMin, fMax;
  float     f1, f2, fReso;
  float     fS0[3];
  float     fDetDist, fDetSwing;

  cout << "Enter the image name which has the detector info: ";
  cin >> sName;
  poImage = new Cimage(sName);
  if (!poImage->bIsAvailable()) return (1);

  poSource   = new Csource(poImage->oHeader);
  poDetector = new Cdetector(poImage->oHeader);

  poSource->vCalcGetS0(fS0);
  (void) poDetector->nList();

  poDetector->nGetResolution(fS0, &fMin, &fMax);
  cout << "Min, Max resolution on detector: " << fMin << ", " << fMax << endl;

  fDetDist  = poDetector->poGoniometer->fGetDistance();
  fDetSwing = poDetector->poGoniometer->fGetSwing();

  cout << "Det dist, swing: " << fDetDist << ", " << fDetSwing << endl;
  do 
    {
      cout << "\nEnter a pixel coord: ";
      cin  >> f1 >> f2;
      fReso = poDetector->fCalcGetResolution(f1, f2, fS0);
      cout << "Resolution: " << fReso << endl;
    }
  while (f1 >= 0.0);

  return (0);

}
